import pyperclip
import rich.console  # pylint: disable=C0415
import rich.syntax  # pylint: disable=C0415

def write_code(code: str, language: str = 'python'):
    pyperclip.copy(code)
    path = 'test.' + language
    syntax = rich.syntax.Syntax(code, rich.syntax.Syntax.guess_lexer(path, code), line_numbers=True)
    console = rich.console.Console()
    console.print(syntax)
    return {'success': True, 'message': 'Code snippet is shown in a user window. Please do not output the code snippet in conversation again.'}
